package xml_tests.XMLParsing;

import java.io.FileReader;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Node;
import org.xml.sax.InputSource;

public class XMLParseSO {


    public static void main(String[] args) throws Exception {
        XPathFactory xpf = XPathFactory.newInstance();
        XPath xpath = xpf.newXPath();
        InputSource xml = new InputSource(new FileReader("stackoverflowquest.xml"));
        Node result = (Node) xpath.evaluate("/tag1", xml, XPathConstants.NODE);
        System.out.println(result);
    }

}